import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Map')
export class Map extends Component {

    private move_speed: number = 1;

    protected childrenNodes: Node[];

    protected onLoad(): void {
        this.childrenNodes = this.node.children;
    }


    start() {

    }

    update(deltaTime: number) {

        for (let index = 0; index < this.childrenNodes.length; index++) {
            const element = this.childrenNodes[index];
            element.setPosition(
                element.position.x,
                element.position.y - this.move_speed
            )

            if (element.position.y <= -480) {
                element.setPosition(
                    element.position.x,
                    480
                )
            }
        }
    }
}


